<template>
	<view>
		<view>
			<uni-steps :options="list" :active="active" />
		</view>
		<view style="padding: 30rpx;">
			<view style="border-bottom: 1px solid #dddddd;padding: 25rpx;">
				<uni-row>
					<uni-col :span="6">
						<b>姓名</b>
					</uni-col>
					<uni-col :span="18">
						<input v-model="realName" focus placeholder="请输入真实姓名" />
					</uni-col>

				</uni-row>
			</view>
			<view style="border-bottom: 1px solid #dddddd;padding: 25rpx;">
				<uni-row>
					<uni-col :span="6">
						<b>身份证号</b>
					</uni-col>
					<uni-col :span="18">
						<input v-model="idCardNo" placeholder="请输入身份证号" />
					</uni-col>
				</uni-row>
			</view>
		</view>
		<view style="padding: 30rpx;">
			<view>
				<uni-file-picker limit="1" title="上传人像面" @select="selectFront"></uni-file-picker>
			</view>
			<view>
				<uni-file-picker limit="1" title="上传国徽面" @select="selectBack"></uni-file-picker>
			</view>
		</view>
		<view style="text-align: center; margin-top: 20rpx;">
			<button type="primary" size="mini" style="width: 80%;" @click="workmanInfo()">
				下一步
			</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				files:[],
				realName: "",
				idCardNo: "",
				active: 0,
				list: [{
					title: '身份认证'
				}, {
					title: '设置服务'
				}, {
					title: '资质审核'
				}, {
					title: '完成'
				}],
			}
		},
		methods: {
			selectFront(e) {
				console.log('选择人像文件：', e)
				let file=e.tempFiles[0].file
				// console.log(e.tempFiles[0].file);
				uni.request({
					url: 'http://120.46.197.40:8080/api/userAuthentication/checkIdCard',
					method: 'POST',
					data: {
						"file":file,
						"type":1
					},
					header: {
						'content-type': 'multipart/form-data'
					},
					success: (res) => {
						console.log(res);
						this.files.push(file);
					}
				});
				
			},
			selectBack(e) {
				console.log('选择国徽文件：', e)
				let file=e.tempFiles[0].file
				// console.log(e.tempFiles[0].file);
				uni.request({
					url: 'http://120.46.197.40:8080/api/userAuthentication/checkIdCard',
					method: 'POST',
					data: {
						"file":file,
						"type":2
					},
					header: {
						'content-type': 'multipart/form-data'
					},
					success: (res) => {
						console.log(res);
						this.files.push(file);
					}
				});
			},
			workmanInfo(){
				uni.request({
					url: 'http://120.46.197.40:8080/api/userAuthentication/updateUserInfo',
					method: 'POST',
					data: {
						"idCardNo": this.idCardNo,
						"realName": this.realName,
						"userId":this.userId,
						"files":this.files,
					},
					header: {
						'content-type': 'multipart/form-data'
					},
					success: (res) => {
						console.log(res);
						//if(res.data.code==0){
							uni.navigateTo({
								url:"/pages/home/workman/service"
							})
						//}
					}
				});
			}

		}
	}
</script>

<style>

</style>
